/***********************************************
 * Title:       ColMapping.java
 * Description: ColMapping.java
 * Author:      NiDeveloper
 * Create Date: 2010-4-24
 * CopyRight:   CopyRight(c)@2009
 * Company:     TJUSCS
 * Version:     1.0
 ***********************************************
 */
package com.younker.waf.excelUpload;

import java.util.HashMap;
import java.util.Map;

/**
 * @author NiDeveloper
 *
 */
public class ColMapping
{
        private String colName;
        private String attrName;
        private Map<String, ValueMapping> valueMappings = new HashMap<String, ValueMapping>();
        /**
         * @return the colName
         */
        public String getColName()
        {
                return colName;
        }
        /**
         * @param colName the colName to set
         */
        public void setColName(String colName)
        {
                this.colName = colName;
        }
        /**
         * @return the attrName
         */
        public String getAttrName()
        {
                return attrName;
        }
        /**
         * @param attrName the attrName to set
         */
        public void setAttrName(String attrName)
        {
                this.attrName = attrName;
        }
        
        
        public String getJavaValue( String excelValue)
        {
                ValueMapping valueMapping = valueMappings.get(excelValue);
                if( valueMapping == null )
                        return excelValue;
                return valueMappings.get(excelValue).getJavaValue();
        }
        
        
        /**
         * @param valueMappings the valueMappings to set
         */
        public void setValueMappings(Map<String, ValueMapping> valueMappings)
        {
                this.valueMappings = valueMappings;
        }
        
        public void addValueMapping( ValueMapping valueMapping )
        {
                valueMappings.put(valueMapping.getExcelValue(), valueMapping);
        }
        /* (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        @Override
        public String toString()
        {
                return "ColMapping [attrName=" + attrName + ", colName=" + colName
                                + ", valueMappings=" + valueMappings + "]";
        }
}
